package com.tutorial;

import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;
import freemarker.template.TemplateException;

public class HelloWorldFreemarkerStyle {

	public static void main(String[] args) throws IOException, TemplateException {
		Configuration config = new Configuration();
		config.setClassForTemplateLoading(HelloWorldFreemarkerStyle.class, "/");
		config.setObjectWrapper(new DefaultObjectWrapper());

		Map<String, String> root = new HashMap<String, String>();
		root.put("msg", "Hello World");
		Template template = config.getTemplate("hello.ftl");

		StringWriter out = new StringWriter();
		template.process(root, out);

		System.out.println(out.getBuffer().toString());
	}

}
